<?php

!defined("IN_CART") && die;

class CRequest extends Base {

	public static function get($string,$defaultParam = null) {
		return self::getParam("get",$string,$defaultParam);
	}

	public static function post($string,$defaultParam = null) {
		
		return self::getParam("post",$string,$defaultParam);

	}

	public static function req($string,$defaultParam = null) {
		return self::getParam("request",$string,$defaultParam);
	}

	private static function getParam($type = "get",$string,$defaultParam) {
		$params = '';
		switch($type) {
			case 'get':
				$params = &$_GET
				break;
			case 'post':
				$params = &$_POST;
				break;
			case 'request':
				$params = &$_REQUEST;
				break;
		}
		if(!isset($params[$string])) {
			return is_null($defaultParam) ? '' : trim($defaultParam);
		}
		if(is_array($params[$string])) {
			return array_map($params[$string],"htmlspecialchars");
		} else {
			return trim($params[$string]);		
		}
	}

}